#!/bin/bash
centos_6(){
centos6=`awk -F 'release' '{print $2}' /etc/redhat-release |cut -d '.' -f1|cut -d ' ' -f2`
if [ $centos6 -eq 6 ];then 
   > /tmp/xujun.txt
   uid=`cat /etc/passwd|awk -F "[:]" '{print $3}'|xargs -n 1`
   for n in $uid;do
      if [ $n -ge 500 ];then
            user_uid=`cat /etc/passwd|awk -F ':' '{print $1":"$3}'|grep $n`
            echo $user_uid
            echo $user_uid >> /tmp/xujun.txt
      fi
   done
   num=`cat /tmp/xujun.txt|wc -l`
   echo "USER is $num" 
fi
}
centos_6

centos_7(){
centos7=`awk -F 'release' '{print $2}' /etc/redhat-release |cut -d '.' -f1|cut -d ' ' -f2`
if [ $centos7 -eq 7 ];then
    > /tmp/xujun.txt
    uid=`cat /etc/passwd|awk -F "[:]" '{print $3}'|xargs -n 1`
    for n in $uid;do
       if [ $n -ge 1000 ];then
            user_uid=`cat /etc/passwd|awk -F ':' '{print $1":"$3}'|grep $n`
            echo $user_uid
            echo $user_uid >> /tmp/xujun.txt
       fi
    done
    num=`cat /tmp/xujun.txt|wc -l`
    echo "USER is $num"
fi
}
centos_7
